/**
 * 
 */
package org.youisoft.summer.evaluator.function.clustering;

import java.util.List;

/**
 * @author zijiang.jl
 *
 */
public class KMeansFunction extends AbstractKSeriesFunction{


	@Override
	public String getName() {
		return "kmeans";
	}

	@Override
	protected void adjustCenter(double[] center,List<Number> points, int[] centerIndex) {
		for(int j=0;j<center.length;j++){
			double temp=0;
			int cnt=0;
			for(int i=0;i<centerIndex.length;i++){
				if(j==centerIndex[i]){
					temp+=points.get(i).doubleValue();
					cnt++;
				}
			}
			
			if(cnt!=0) center[j]=temp/cnt;
		}
		
	}
		
}
